package com.ymatou.iapi.livebuyer.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.CreateGroupBean;
import com.ymatou.iapi.livebuyer.service.CreateGroupCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.TestDataManager;
/**
*后台创建群组
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CreateGroup{
	private static CreateGroupBean creategroupBean;
	private static CreateGroupCall creategroupCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("后台创建群组");
	}

	@Before
	public void caseUp() {
		creategroupBean=new CreateGroupBean();
		creategroupCall=new CreateGroupCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(creategroupCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CreateGroup_001() {
		Logger.start(true,"后台创建群组成功");
		try {
			creategroupBean.setGroupName("AutoTestGroup"+TestDataManager.getRandomNum(6));
			creategroupCall.setData(creategroupBean);
			creategroupCall.callService();			
			Logger.verifyEquals("200", creategroupCall.getString("code"), "验证code");
			Logger.verifyNotNull(creategroupCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CreateGroup_002() {
		Logger.start(true,"不输入groupName失败");
		try {
			creategroupCall.setData(creategroupBean);
			creategroupCall.callService();			
			Logger.verifyEquals("100", creategroupCall.getString("code"), "验证code");
			Logger.verifyIsContains("无效的群组名称", creategroupCall.getString("message"), "验证message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}